package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootZnx;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Getter
@Setter
public class FootZnxSearchForm extends SearchForm implements Serializable {
    private static final long serialVersionUID = 8090668615941861553L;
    protected String userName;
    protected Long sender;
    protected Long resiver;
    protected Boolean readed;

    public Example buildSearchCommond() {
        Example example = new Example(FootZnx.class);
        Example.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(sender)) {
            criteria.andEqualTo("sender", sender);
        }
        if (!StringUtils.isEmpty(resiver)) {
            criteria.andEqualTo("resiver", resiver);
        }
        if (null != readed) {
            criteria.andEqualTo("readed", readed);
        }
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("sendTime").desc();
        return example;
    }

}
